<?php

namespace services\common;

use common\components\Service;
use common\models\common\ActionBehavior;

/**
 * Class ActionBehaviorService
 * @package services\common
 */
class ActionBehaviorService extends Service
{
    /**
     * @return array|\yii\db\ActiveRecord[]
     */
    public function getList()
    {
        return ActionBehavior::find()
            ->andWhere(['status' => 1])
            ->asArray()
            ->all();
    }

    /**
     * 重组数据列表
     *
     * @return array
     */
    public function getAllData()
    {
        $list = $this->getList();
        $data = [];

        if (!empty($list)) {
            foreach ($list as $item) {
                $key = [];
                $key[] = $item['app_id'];
                $key[] = $item['url'];
                $key[] = $item['action'];
                $data[implode('|', $key)] = $item;
            }

        }

        return $data;
    }
}